package com.xupt.ttms.util;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.Set;
@Component
@Slf4j
public class RedisUtil {
    private static RedisTemplate redisTemplate;
    @Qualifier("redisTemplate")
    @Resource
    private RedisTemplate getRedisTemplate;
    //初始化redisTemplate
    @PostConstruct
    private void init(){
        redisTemplate = this.getRedisTemplate;
    }
    /**
     * 删除redis中指定前缀的key
     * @param param
     * @return
     */
    public static long deleteCaChe(String param){
        Set keys = redisTemplate.keys(param);
        return redisTemplate.delete(keys);
    }
}